import { request } from "@/utils/request"
import qs from 'querystring'

const prefix = '/notes'

/**
 * 获取进出记录
 * @returns 
 */
export const getNotesRequest = () => {
	return request.get(`${prefix}/getNotes`)
}

/**
 * 删除进出记录
 * @param params 
 * @returns 
 */
export const deleteNotesRequest = (params: number) => {
	return request.delete(`${prefix}/deleteNotes/${params}`)
}

interface notetesParams {
	hourNum: number,
	startNum: number,
	monthNum: number,
	dayNum: number,
	notes: string,
}
/**
 * 添加出入记录
 * @param params 
 * @returns 
 */
export const addNotesRequest = (params: notetesParams) => {
	return request.post(`${prefix}/addNotes`, params)
}

/**
 * 修改出入记录
 * @param params 
 * @returns 
 */
export const reviseNotesRequest = (params: notetesParams) => {
	return request.put(`${prefix}/reviseNotes`, params)
}

interface searchParams {
	[s: string]: any;
	inTime: string | undefined
	outTime: string | undefined
}
/**
 * 根据条件筛选车位
 * @param params 
 * @returns 
 */
export const searchRequest = (params: searchParams) => {
	return request.get(`${prefix}/search?${qs.stringify(params)}`)
}
